/**
 * Copyright (C), 2019-2022, 宇信融汇
 * FileName: JdkProxyFactory
 * Author:   86182
 * Date:     2022/4/7 14:38
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 86182           修改时间           版本号              描述
 */
package test.jdkproxy;

import test.jdkproxy.impl.ServiceImpl;

import java.lang.reflect.Proxy;

/**
 * @Classname JdkProxyFactory
 * @Description TODO
 * @Date 2022/4/7 14:38
 * @Created by 86182
 */
public class JdkProxyFactory {
    public static Object getProxy(Object target) {
        return Proxy.newProxyInstance(target.getClass().getClassLoader(), //类加载，用来加载代理对象
                target.getClass().getInterfaces(),//被代理类的一些接口
                new DebugInvocationHandler(target));//现实InvocationHandler接口
    }

    public static void main(String[] args) {
        Service service = (Service) JdkProxyFactory.getProxy(new ServiceImpl());
        service.send("java");
    }
}
